//
//  HMHomeToplistCell.m
//  HowToDo
//
//  Created by Stan on 2017-01-05.
//  Copyright © 2017 KY. All rights reserved.
//

#import "HMHomeToplistCell.h"

@interface HMHomeToplistCell ()




@end

static CGFloat defaultMargin = 15;
@implementation HMHomeToplistCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCellUI];
    }
    return self;
}




- (void)createCellUI{
//    创建封面
    self.coverPhotoImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.coverPhotoImageView];
    
    self.coverPhotoImageView.image = [UIImage imageNamed:@"201612271441573272"];
    self.coverPhotoImageView.contentMode = UIViewContentModeScaleToFill;
    
    [self.coverPhotoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.offset(defaultMargin);
        make.bottom.offset(- defaultMargin);
        make.width.offset(85);
        make.height.mas_lessThanOrEqualTo(85);
    }];
    
//    创建标题
    self.resourceNameLabel = [UILabel hm_labelWithText:@"十大经典鬼故事十大经典鬼故事十大经典鬼故事十大经典鬼故事十大经典鬼故事十大经典鬼故事十大经典鬼故事" fontSize:k_FONT_NORMAL colorWithHex:0x414141];
    self.resourceNameLabel.numberOfLines = 1;
    [self.contentView addSubview:self.resourceNameLabel];
    
    [self.resourceNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(18);
        make.left.equalTo(self.coverPhotoImageView.mas_right).offset(defaultMargin);
        make.right.offset(-defaultMargin);
    }];
    
    [self.contentView layoutIfNeeded];
    
//    创建简介
    self.resourceContentLabel = [UILabel hm_labelWithText:@"十个让你看了不敢一个人睡觉的经典鬼故事十个让你看了不敢一个人睡觉的经典鬼故事十个让你看了不敢一个人睡觉的经典鬼故事十个让你看了不敢一个人睡觉的经典鬼故事" fontSize:k_FONT_SMALL colorWithHex:0x7f7f7f];
    self.resourceContentLabel.numberOfLines = 3;
    [self.contentView addSubview:self.resourceContentLabel];
    
    [self.resourceContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.resourceNameLabel.mas_bottom).offset(11);
        make.left.equalTo(self.coverPhotoImageView.mas_right).offset(defaultMargin);
        make.right.offset(-defaultMargin);
    }];
    
    
}

#pragma 懒加载
- (UILabel *)resourceContentLabel{
    if (_resourceContentLabel == nil) {
        _resourceContentLabel = [[UILabel alloc]init];
    }
    return _resourceContentLabel;
}

- (UILabel *)resourceNameLabel{
    if (_resourceNameLabel == nil) {
        _resourceNameLabel = [[UILabel alloc]init];
    }
    return _resourceNameLabel;
}
@end
